if object_id('sp_ContentTag_Insert') is not null
drop proc sp_ContentTag_Insert
go
create proc sp_ContentTag_Insert
@ContentString	ntext,
@WebsiteLinkID	int
as
begin
	begin tran
	insert into ContentTag(ContentString,WebsiteLinkID)
	values (@ContentString,@WebsiteLinkID)
	select @@IDENTITY
	if(@@ERROR<>0)
	begin
		rollback tran
	end
	else
	begin
		commit tran
	end
end
go
if object_id('sp_ContentTag_Update') is not null
drop proc sp_ContentTag_Update
go
create proc sp_ContentTag_Update
@ContentTagID	int,
@ContentString	ntext,
@WebsiteLinkID	int,
@Del	bit
as
begin
	begin tran
		Update ContentTag
		set ContentString = @ContentString,
		WebsiteLinkID = @WebsiteLinkID,
		Del = @Del
		where ContentTagID = @ContentTagID
		
		if(@@ERROR<>0)
		begin
			rollback tran
		end
	commit tran
end
go
if object_id('sp_ContentTag_GetAll') is not null
drop proc sp_ContentTag_GetAll
go
create proc sp_ContentTag_GetAll
as
begin
	begin tran
		select * from ContentTag
	commit tran
end
go
if object_id('sp_ContentTag_Select') is not null
drop proc sp_ContentTag_Select
go
create proc sp_ContentTag_Select
@ContentTagID int
as
begin
	begin tran
	 select * 
	 from ContentTag 
	 where ContentTagID=@ContentTagID
	commit tran
end
go
---website
if object_id('sp_Website_Insert') is not null
drop proc sp_Website_Insert
go
create proc sp_Website_Insert
@WebsiteName	nvarchar(500)
	
as
begin
	begin tran
		Insert Website (WebsiteName) values (@WebsiteName)
		if(@@ERROR<>0)
		begin
			rollback tran
		end
		else
		begin
			select @@IDENTITY
		end
	commit tran
end
go
if object_id('sp_Website_Update') is not null
drop proc sp_Website_Update
go
create proc sp_Website_Update
@WebsiteID	int,
@WebsiteName	nvarchar(500),
@Del	bit
as
begin
	begin tran
		Update Website
		set WebsiteName  = @WebsiteName,
		Del = @Del
		where WebsiteID=@WebsiteID
		if(@@ERROR<>0)
		begin
			rollback tran
		end
	commit tran
end
go
if object_id('sp_Website_GetAll') is not null
drop proc sp_Website_GetAll
go
create proc sp_Website_GetAll
as
begin
	begin tran
		select * from Website
	commit tran
end
go
if object_id('sp_Website_Select') is not null
drop proc sp_Website_Select
go
create proc sp_Website_Select
@WebsiteID	int
as
begin
	begin tran
	select * from Website where WebsiteID=@WebsiteID
	commit tran
end
go
--- Website Link
if object_id('sp_WebsiteLink_Insert') is not null
drop proc sp_WebsiteLink_Insert
go
create proc sp_WebsiteLink_Insert
@WebsiteLinkName	nvarchar(MAX),
@WebsiteID	int
as
begin
	begin tran
		insert into WebsiteLink(WebsiteLinkName,WebsiteID)
		values (@WebsiteLinkName,@WebsiteID)
		if(@@ERROR<>0)
		begin
			rollback tran
		end
		else
		begin
			select @@IDENTITY
		end
	commit tran
end
go
if object_id('sp_WebsiteLink_Update') is not null
drop proc sp_WebsiteLink_Update
go
create proc sp_WebsiteLink_Update
@WebsiteLinkID	int,
@WebsiteLinkName	nvarchar(MAX),
@WebsiteID	int,
@Del	bit
	
as
begin
	begin tran
		Update WebsiteLink
		set WebsiteLinkName = @WebsiteLinkName,
		WebsiteID=@WebsiteID,
		Del=@Del
		where WebsiteLinkID=@WebsiteLinkID
		if(@@ERROR<>0)
		begin
			rollback tran
		end
	commit tran
end
go
if object_id('sp_WebsiteLink_GetAll') is not null
drop proc sp_WebsiteLink_GetAll
go
create proc sp_WebsiteLink_GetAll
as
begin
	begin tran
	 select * from WebsiteLink
	commit tran
end
go
if object_id('sp_WebsiteLink_Select') is not null
drop proc sp_WebsiteLink_Select
go
create proc sp_WebsiteLink_Select
@WebsiteLinkID	int
as
begin
	begin tran
		select * 
		from WebsiteLink 
		where WebsiteLinkID=@WebsiteLinkID
	commit tran
end
go
